package demo04;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author: WangPeng
 * @createTime: 2022/11/04 16:19
 * @description:
 * @version: v1.0
 */
public class Test02 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(3);
        list.add(4);
        list.add(6);
        Comparator<Integer> comparator1 = (o1,o2)->o1-o2;
        Comparator<Integer> comparato2 = (o1,o2)->Integer.compare(o1,o2);
        //静态方法的引用
        Comparator<Integer> comparator3 = Integer::compare;

        Collections.sort(list,comparator3);
        System.out.println(list);
    }
}
